package br.ufrgs.inf.cwsmart.description;

import java.util.Arrays;
import java.util.List;

import br.ufrgs.inf.cwsmart.core.CWSType;
import br.ufrgs.inf.cwsmart.core.WebService;
import br.ufrgs.inf.cwsmart.exception.FrameworkException;

/**
 * Abstract class that represents a CWS.
 * 
 * @author Rodrigo S Lumertz
 *
 */
public abstract class CWSDescription {

	protected String cwsPath;
	protected String language;
	protected List<String> wsdlPaths;
	
	//parsed information
	protected List<WebService> coreComponents;
	protected List<WebService> optionalComponents;
	protected String permissions;
	protected String functionalRequirements;
	protected String nonFunctionalRequirements;
	protected String cwsId;
	protected CWSType cwsType;
	
	public CWSDescription(String cwsPath, String language, String... wsdlPaths) {
		this.cwsPath = cwsPath;
		this.language = language;
		this.wsdlPaths = Arrays.asList(wsdlPaths);
	}
	
	/**
	 * Gets the file that describes de CWS ala bpel for example.
	 * 
	 * @return A byte array that is the CWS file description.
	 */
	public String getCWSPath() {
		return this.cwsPath;
	}
	
	/**
	 * Gets the language of this CWS instance.
	 *  
	 * @return A String with the language name of this CWS.
	 */
	public String getLanguage() {
		return this.language;
	}
	
	/**
	 * @return the wsdlPaths
	 */
	public List<String> getWsdlPaths() {
		return wsdlPaths;
	}

	/**
	 * Gets a list of core components of this CWS
	 * 
	 * @return A list of web services
	 */
	public List<WebService> getCoreComponents() {
		return this.coreComponents;
	}
	
	/**
	 * Gets a list of optional components of this CWS
	 * 
	 * @return A list of web services
	 */
	public List<WebService> getOptionalComponents() {
		return this.optionalComponents;
	}
	
	/**
	 * Gets the permissions for this CWS
	 * 
	 * @return An String with the permission for this CWS 
	 */
	public String getPermissions() {
		return this.permissions;
	}
	
	/**
	 * Gets the functional requirements demanded by this CWS
	 * 
	 * @return A String with requirements
	 */
	public String getFunctionalRequirements() {
		return this.functionalRequirements;
	}
	
	/**
	 * Gets the non functional requirements demanded by this CWS
	 * 
	 * @return A String with requirements
	 */
	public String getNonFunctionalRequirements() {
		return this.nonFunctionalRequirements;
	}
	
	/**
	 * Gets the Id of this CWS.
	 * 
	 * @return A String that identifies this CWS
	 */
	public String getCWSId() {
		return this.cwsId;
	}
	
	/**
	 * Gets the type of this CWS.
	 * 
	 * @return An enumeration element
	 */
	public CWSType getCWSType() {
		return this.cwsType;
	}
	
	/**
	 * Parses the CWS web service description to retrieve the 
	 * properties prior to having the obtained properties stored in the 
	 * repository of CWS descriptions.   
	 * 
	 * @throws FrameworkException
	 */
	public abstract void parse()
		throws FrameworkException;
	
}
